
// PhotoPickerTool.m

#import "PhotoPickerTool.h"

@implementation PhotoPickerTool

+ (void)presentPhotoPickerForSourceType:(UIImagePickerControllerSourceType)sourceType onViewController:(UIViewController *)viewController completion:(void (^)(UIImage *selectedImage, NSError *error))completion {
    UIImagePickerController *imagePicker = [[UIImagePickerController alloc] init];
    imagePicker.sourceType = sourceType;
    imagePicker.delegate = self;
    imagePicker.modalPresentationStyle = UIModalPresentationOverFullScreen;
    imagePicker.modalTransitionStyle = UIModalTransitionStyleCrossDissolve;

    [viewController presentViewController:imagePicker animated:YES completion:nil];
}
- (void)imagePickerControllerDidCancel:(UIImagePickerController *)picker {
    [picker dismissViewControllerAnimated:YES completion:nil];
//    if (completion) {
//        completion(nil, nil);
//    }
}

- (void)imagePickerController:(UIImagePickerController *)picker didFinishPickingMediaWithInfo:(NSDictionary<UIImagePickerControllerInfoKey,id> *)info {
    UIImage *selectedImage = info[UIImagePickerControllerOriginalImage];
    [picker dismissViewControllerAnimated:YES completion:nil];
//    if (completion) {
//        completion(selectedImage, nil);
//    }
}

@end
